package com.itheima.service.impl;

import com.itheima.service.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
public class ImageServiceImpl implements ImageService {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    private static final String UPLOADED_IMAGES_SET = "uploadedImages";
    private static final String USED_IMAGES_SET = "usedImages";


    // 保存上传成功的图片地址
    @Override
    public void saveUploadedImage(String url) {
        redisTemplate.opsForSet().add(UPLOADED_IMAGES_SET, url);
    }

    // 保存数据库中使用的图片地址
    @Override
    public void saveUsedImage(String url) {
        redisTemplate.opsForSet().add(USED_IMAGES_SET, url);
    }
}
